﻿using Microsoft.AspNetCore.Http;
using System.ComponentModel.DataAnnotations;

namespace SenGe.Domain
{
    /// <summary>
    /// 用户模型
    /// </summary>
    [SenTableName("sen_user")]
    public class SenUser : BaseInfoEntity
    {
        /// <summary>
        /// 用户昵称
        /// </summary>
        public required string Name { get; set; }
        /// <summary>
        /// 登录用户名
        /// </summary>
        public required string UserName { get; set; }
        /// <summary>
        /// 登录用户密码
        /// </summary>
        public required string PassWord { get; set; }
        /// <summary>
        /// 用户头像
        /// </summary>
        public string? Avatar { get; set; }
        /// <summary>
        /// 手机号码
        /// </summary>
        public string? Phone { get; set; }
        /// <summary>
        /// 用户性别(0女1男2未知)
        /// </summary>
        public SysGender Gender { get; set; } = SysGender.Unknown;
        /// <summary>
        /// 用户真实姓名
        /// </summary>
        public string? TrueName { get; set; }
        /// <summary>
        /// 用户出生日期
        /// </summary>
        public DateTime? Birthday { get; set; }
        /// <summary>
        /// 身份证号码
        /// </summary>
        public string? IdCard { get; set; }
        /// <summary>
        /// 居住地址
        /// </summary>
        public string? Address { get; set; }
        /// <summary>
        /// 备注说明
        /// </summary>
        public string? Remarks { get; set; }
        /// <summary>
        /// 最近一次登录时间
        /// </summary>
        public DateTime? LastLoginTime { get; set; }
    }

    /// <summary>
    /// 用户注册模型
    /// </summary>
    public class UserRegisterModel : BaseInfoEntity
    {
        /// <summary>
        /// 用户昵称
        /// </summary>
        [Required(AllowEmptyStrings = false, ErrorMessage = "用户昵称不能为空！")]
        [StringLength(20, MinimumLength = 2, ErrorMessage = "用户昵称长度为2至20个字符！")]
        [NameValidation]
        public required string Name { get; set; }
        /// <summary>
        /// 用户名
        /// </summary>
        [Required(AllowEmptyStrings = false, ErrorMessage = "用户名不能为空！")]
        [StringLength(20, MinimumLength = 3, ErrorMessage = "用户名长度为3至20个字符！")]
        [UserNameValidation]
        public required string UserName { get; set; }
        /// <summary>
        /// 用户密码
        /// </summary>
        [Required(AllowEmptyStrings = false, ErrorMessage = "用户密码不能为空！")]
        [StringLength(50, MinimumLength = 6, ErrorMessage = "用户密码长度为6至50个字符！")]
        public required string Password { get; set; }
        /// <summary>
        /// 确认用户密码
        /// </summary>
        [Required(AllowEmptyStrings = false, ErrorMessage = "确认密码不能为空！")]
        [StringLength(50, MinimumLength = 6, ErrorMessage = "确认密码长度为6至50个字符！")]
        [Compare("Password", ErrorMessage = "两次输入密码不匹配！")]
        public required string ConfirmPassword { get; set; }
        /// <summary>
        /// 用户头像
        /// </summary>
        public IFormFile? AvatarFile { get; set; }
        /// <summary>
        /// 头像地址
        /// </summary>
        public string? Avatar { get; set; }
        /// <summary>
        /// 手机号码
        /// </summary>
        [PhoneNumberValidation]
        public string? Phone { get; set; }
        /// <summary>
        /// 用户真实姓名
        /// </summary>
        public string? TrueName { get; set; }
        /// <summary>
        /// 用户性别(0女1男2未知)
        /// </summary>
        public SysGender Gender { get; set; } = SysGender.Unknown;
        /// <summary>
        /// 用户出生日期
        /// </summary>
        public DateTime? Birthday { get; set; }
        /// <summary>
        /// 身份证号码
        /// </summary>
        public string? IdCard { get; set; }
        /// <summary>
        /// 居住地址
        /// </summary>
        public string? Address { get; set; }
        /// <summary>
        /// 备注说明
        /// </summary>
        public string? Remarks { get; set; }
        /// <summary>
        /// 操作结果
        /// 0为失败，1为成功
        /// </summary>
        public int Result { get; set; } = 0;
        /// <summary>
        /// 操作结果信息
        /// </summary>
        public string? ResultMessage { get; set; } = "操作失败！";
    }

    /// <summary>
    /// 登录模型
    /// </summary>
    public class LoginModel
    {
        /// <summary>
        /// 用户名
        /// </summary>
        [Required(AllowEmptyStrings = false, ErrorMessage = "用户名不能为空！")]
        [StringLength(20, MinimumLength = 3, ErrorMessage = "用户名长度为3至20个字符！")]
        public required string UserName { get; set; }
        /// <summary>
        /// 用户密码
        /// </summary>
        [Required(AllowEmptyStrings = false, ErrorMessage = "用户密码不能为空！")]
        [StringLength(50, MinimumLength = 6, ErrorMessage = "用户密码长度为6至50个字符！")]
        public required string Password { get; set; }
        /// <summary>
        /// 操作结果信息
        /// </summary>
        public string? ResultMessage { get; set; } = "操作失败！";
    }
}
